package net.flyinggroup.inspection.controller;

import lombok.extern.slf4j.Slf4j;
import net.flyinggroup.inspection.event.Event;
import net.flyinggroup.inspection.event.Session;
import org.springframework.graphql.data.method.annotation.QueryMapping;
import org.springframework.graphql.data.method.annotation.SchemaMapping;
import org.springframework.stereotype.Controller;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

@Controller
@Slf4j
public class EventController {

    private final List<Event> events = new ArrayList<>();

    public EventController() {
        var event = new Event(1,
                "event1",
                "inside controller",
                LocalDate.of(2023, 8, 21),
                LocalDate.of(2023, 8, 24),
                LocalDate.now().minusDays(180),
                LocalDate.now().minusDays(90),
                "Shen-Zhen",
                "https://spring.io/"
        );
        events.add(event);
    }

    @QueryMapping
    public List<Event> events() {
        return events;
    }

//    @SchemaMapping
//    public List<Session> sessions(Event event) {
//        log.info("Fetching Sessions for event: " + events.toString());
//        var session = new Session(1, "test1", "test1 desc");
//        return List.of(session);
//    }
}
